﻿<UserControl xmlns:my="clr-namespace:GiveAQuiz.QuizManager.Views"
             xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
             x:Class="GiveAQuiz.QuizManager.QuizTaker"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             FontFamily="Trebuchet MS"
             FontSize="18.667"
             Width="900"
             Height="450"
             d:DesignHeight="300"
             d:DesignWidth="400">

  <Grid x:Name="LayoutRoot"
        Background="White">
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="0.932*" />
      <ColumnDefinition Width="0.068*" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto"
                     MinHeight="53" />
      <RowDefinition />
      <RowDefinition Height="Auto"
                     MinHeight="50" />
    </Grid.RowDefinitions>

    <Image Margin="-151,0,0,-87"
           Source="images/background-pencil.jpg"
           Grid.RowSpan="3"
           Opacity="0.3"
           Grid.ColumnSpan="2" Stretch="UniformToFill" />

    <TextBlock HorizontalAlignment="Left"
               TextWrapping="Wrap"
               Text="{Binding Quiz.Name}"
               VerticalAlignment="Top"
               Margin="8,8,0,0"
               FontSize="32"
               d:IsLocked="True" />

    <Grid Margin="8"
          Grid.Row="1"
          Grid.ColumnSpan="2"
          Visibility="{Binding CurrentQuestion, Converter={StaticResource visibilityNullConverter}}">
    	<Grid.RowDefinitions>
    		<RowDefinition Height="0.964*"/>
    		<RowDefinition Height="0.036*"/>
    	</Grid.RowDefinitions>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="0.086*" />
        <ColumnDefinition Width="0.914*" />
      </Grid.ColumnDefinitions>
      <StackPanel Orientation="Horizontal"
                  HorizontalAlignment="Right" Grid.RowSpan="2">
        <TextBlock Margin="0 2"
                   HorizontalAlignment="Right"
                   TextWrapping="NoWrap"
                   Text="{Binding CurrentQuestionNumber, Mode=OneWay}"
                   d:LayoutOverrides="Width, Height" />
        <TextBlock Margin="0 2"
                   HorizontalAlignment="Right"
                   TextWrapping="NoWrap"
                   Text="."
                   d:LayoutOverrides="Width, Height" />
      </StackPanel>
      <ScrollViewer
      	Grid.Column="1"
      	Margin="0" ScrollViewer.VerticalScrollBarVisibility="Auto" BorderBrush="{x:Null}" >
      	<toolkit:TransitioningContentControl x:Name="questionContent"
      		VerticalContentAlignment="Stretch"
      		HorizontalContentAlignment="Stretch"
      		DataContext="{Binding CurrentQuestion}"
      		Content="{Binding AnswerPanel}"
      		Transition="DefaultTransition" />
      </ScrollViewer>
      <TextBlock Margin="0,0,3,0" TextWrapping="Wrap" Text="(For Questions with multiple choices, you can use the numeric keys to select the appropriate answer.)" VerticalAlignment="Top" d:LayoutOverrides="Width" Grid.Row="1" Grid.Column="1" FontSize="9.333" FontStyle="Italic"/>
    </Grid>
    <StackPanel HorizontalAlignment="Right"
                Orientation="Horizontal"
                Grid.ColumnSpan="2">
      <TextBlock TextWrapping="Wrap"
                 Text="("
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center"
                 Margin="0,8" />
      <TextBlock TextWrapping="Wrap"
                 Text="{Binding Quiz.QuizDefinition.QuizName}"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center"
                 Margin="0,8" />
      <TextBlock TextWrapping="Wrap"
                 Text=")"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center"
                 Margin="0,8" />
    </StackPanel>
    <StackPanel Margin="8,8,0,8"
                Orientation="Horizontal"
                Grid.Row="2"
                VerticalAlignment="Center"
                Visibility="{Binding HasTimeLimit, Converter={StaticResource visibilityConverter}}"
                HorizontalAlignment="Left"
                Grid.ColumnSpan="2">
      <TextBlock TextWrapping="Wrap"
                 Text="Time Left:"
                 Margin="0"
                 d:LayoutOverrides="Width"
                 VerticalAlignment="Center" />
      <TextBlock TextWrapping="Wrap"
                 Text="{Binding TimeLeft, StringFormat=h\\:mm\\:ss}"
                 Margin="2,0,0,0"
                 VerticalAlignment="Center"
                 FontWeight="Bold" />

    </StackPanel>

    <StackPanel Margin="8"
                Orientation="Horizontal"
                Grid.Row="2"
                d:LayoutOverrides="Height, GridBox"
                Grid.ColumnSpan="2"
                HorizontalAlignment="Right">
      <Button Content="Cancel Quiz"
              Command="{Binding CancelCommand}"
              Margin="2,0" />
      <Button x:Name="prevButton"
              Command="{Binding PrevQuestionCommand}"
              Content="Prev"
              Margin="2,0" />
      <Button x:Name="nextButton"
              Command="{Binding NextQuestionCommand}"
              Content="Next"
              Margin="2,0" />
      <Button x:Name="finishButton"
              Command="{Binding FinishQuizCommand}"
              Content="Finish"
              Margin="2,0" />
    </StackPanel>
    <toolkit:BusyIndicator IsBusy="{Binding NotStarted}"
                           OverlayStyle="{StaticResource busyIndicatorBack}"
                           ProgressBarStyle="{StaticResource busyIndicatorProgressBar}"
                           VerticalAlignment="Stretch"
                           HorizontalAlignment="Stretch"
                           Grid.RowSpan="3"
                           Grid.ColumnSpan="2"
                           d:IsLocked="True">
      <toolkit:BusyIndicator.BusyContent>
        <my:QuizTakerIntroView Width="640"
                               Height="320" />
      </toolkit:BusyIndicator.BusyContent>
    </toolkit:BusyIndicator>
    <toolkit:BusyIndicator IsBusy="{Binding IsBusy}"
                           OverlayStyle="{StaticResource busyIndicatorBack}"
                           BusyContent="Please Wait..."
                           Grid.RowSpan="3"
                           Grid.ColumnSpan="2"
                           d:IsLocked="True" />
    <TextBlock HorizontalAlignment="Right"
               TextWrapping="NoWrap" 
               Text="{Binding ErrorMessage}"
               VerticalAlignment="Bottom"
               Grid.Row="1"
               Grid.ColumnSpan="2"
               Margin="8"
               Foreground="Red"
               FontStyle="Italic" />

  </Grid>
</UserControl>
